package vip.liux.contracts.models.coupon;

import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import vip.liux.contracts.shared.enums.coupon.UsedTag;
import vip.liux.domain.entities.auditing.CreationAuditedEntity;

import java.time.LocalDateTime;


@Getter
@Setter
@Entity
@Table(name = "shop_user_coupon")
public class UserCoupon extends CreationAuditedEntity<Long> {

    /**
     * 优惠券编号
     */
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JoinColumn(name = "coupon_no", nullable = false, referencedColumnName = "coupon_no")
    private Coupon coupon;

    /**
     * 用户id
     */
    @Column(name = "user_id", nullable = false)
    private Long userId;

    /**
     * 优惠券券码
     */
    @Column(name = "`code`", nullable = false)
    private String code;

    /**
     * 使用订单订单编号
     */
    @Column(name = "order_no", length = 256)
    private String orderNo;

    /**
     * 使用状态（0:未使用，1：已使用）
     */
    @Enumerated(EnumType.ORDINAL)
    @Column(name = "used_tag", nullable = false)
    private UsedTag usedTag;

    /**
     * 使用时间
     */
    @Column(name = "used_time")
    private LocalDateTime usedTime;

    /**
     * 领取时间
     */
    @Column(name = "receive_time")
    private LocalDateTime receiveTime;
}